package model;
import java.awt.Color;
import java.awt.geom.Rectangle2D;
/** * An abstract class to model a generic prescription object * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer * */
public abstract class PrescriptionObject {
	
	protected int x;
	protected int y;
	protected int resizeX;
	protected int resizeY;
	private String name;
	protected float lineWidth;
	private Color fillColour;
	private Color textColour;
	private boolean isResizing;
	private boolean isDragging;
	private boolean isSelected;
	private boolean isHoverOver;
	private Color lineColour;
	protected Rectangle2D[] resizeRecs;
	private boolean isTransparent;
	public PrescriptionObject(
			int x,
			int y,
			Color lineColour,
			float lineWidth,
			Color fillColour,
			Color textColour){
		this.x = x;
		this.y = y;
		this.lineColour = lineColour;
		this.lineWidth = lineWidth;
		this.fillColour = fillColour;
		this.textColour = textColour;
		isDragging = false;
		isSelected = false;
		isHoverOver = false;
		isResizing = false;
		updateResizePoints();
	}
	
	/**
	 * Checks whether a current point is inside the box's bounds.
	 * @param x the x coordinate of point to be checked
	 * @param y the y coordinate of point to be checked
	 * @return true if the point is inside the box
	 */
	public abstract boolean checkBounds(int x, int y);
		/**	 * Updates the resize square coordinates according to objects dimensions	 */	public abstract void updateResizePoints();		/**	 * Gets the width of the object	 * @return the integer representing the width of the object	 */
	public abstract int getWidth();		/**	 * Gets the height of the object	 * @return the integer representing the height of the object	 */
	public abstract int getHeight();
	/**
	 * @param lineWidth the new line width for this object
	 */
	public void setLineWidth(float lineWidth){
		this.lineWidth = lineWidth;
	}
	
	/**
	 * Gets the line width of the object
	 * @return float, the line width for this object
	 */
	public float getLineWidth(){
		return lineWidth;
	}
	
	/**
	 * Sets the line colour of the object 
	 * @param newColour an {@link java.awt.Color} object representing the colour the line will become
	 */
	public void setLineColour(Color newColour){
		this.lineColour = newColour;
	}
	
	/**
	 * Create the line colour for this object using RGB values
	 * 
	 * @param red the red component of the RGB
	 * @param green the green component of the RGB
	 * @param blue the blue component of the RGB
	 */
	public void setLineColour(int red, int green, int blue){
		this.lineColour = new Color(red, green, blue);
	}
	
	/**
	 * Gets the current line colour
	 * @return current line colour of box
	 */
	public Color getLineColour(){
		return this.lineColour;
	}
	
	/**	 * Gets the red RGB component of the line colour
	 * @return the red RGB value of the line colour
	 */
	public int getLineColourRed(){
		return this.lineColour.getRed();
	}
	/**	 * Gets the green RGB component of the line colour
	 * @return the green RGB value of line colour
	 */
	public int getLineColourGreen(){
		return this.lineColour.getGreen();
	}
	/**	 * Gets the blue RGB component of the line colour
	 * @return the blue RGB value of line colour
	 */
	public int getLineColourBlue(){
		return this.lineColour.getBlue();
	}
	/**
	 * Sets the x coordinate of the object
	 * @param x the x coordinate to set box object location
	 */
	public void setX(int x){
		this.x = x;
		updateResizePoints();
	}
	/**
	 * Gets the x coordinate of the object
	 * @return the x coordinate of the object
	 */
	public int getX(){
		return x;
	}
	/**
	 * Sets the y coordinate of the object
	 * @param y the y coordinate of the object
	 */
	public void setY(int y){
		this.y = y;
		updateResizePoints();
	}
	/**
	 * Gets the y coordinate of the object
	 * @return the y coordinate of the object
	 */
	public int getY(){
		return y;
	}
	/**
	 * Sets the resized x coordinate
	 * @param x the x coordinate to set the objects location
	 */
	public void setResizeX(int x){
		this.resizeX = x;
	}
	/**
	 * Gets the resized x coordinate
	 * @return the x coordinate of the resized object
	 */
	public int getResizeX(){
		return resizeX;
	}
	/**
	 * Sets the resized y coordinate 
	 * @param y the y coordinate of the resized object
	 */
	public void setResizeY(int y){
		this.resizeY = y;
	}
	/**
	 * Gets the resized y coordinate
	 * @return the y coordinate of the resized object
	 */
	public int getResizeY(){
		return resizeY;
	}
	/**
	 * Sets the state of resizing of an object
	 * @param resize if object is resizing return true
	 */
	public void setResizing(boolean resize){
		isResizing = resize;
	}
	/**
	 * Check the state of the object and whether it is currently resizing 
	 * @return if object is resizing return true
	 */
	public boolean isResizing(){
		return isResizing;
	}
	/**
	 * Sets whether the mouse is hovering over the object
	 * @param hover if mouse is hovered over object set to true
	 */
	public void setHoverOver(boolean hover){
		isHoverOver = hover;
	}
	
	/**
	 * Checks if the mouse is currently hovering over the object
	 * @return if mouse is over object return true
	 */
	public boolean isHoverOver(){
		return isHoverOver;
	}
	/**
	 * Sets whether the object is selected
	 * @param selected set to true if an item is selected
	 */
	public void setSelected(boolean selected){
		isSelected = selected;
	}

	/**
	 * Checks if the object is currently selected
	 * @return if an object is selected this method will return true
	 */
	public boolean isSelected(){
		return isSelected;
	}
	/**
	 * Sets the state of the object and whether it is currently being dragged
	 * @param drag if box object is being dragged set this to true
	 */
	public void setDrag(boolean drag){
		isDragging = drag;
	}
	/**
	 * Checks whether the object is currently in a dragged state
	 * @return if dragging true is returned
	 */
	public boolean isDragging(){
		return isDragging;
	}
		/**	 * Checks the bounds of the object and whether it can be resized	 * @param x the x coordinate to check	 * @param y the y coordinate to check	 * @return returns true if it can be resized	 */
	public boolean checkResizeBounds(int x, int y){
		if(x >= (getResizeX() + 1) &&
				x <= (getResizeX() + 6) &&
				y >= (getResizeY() + 1) &&
				y <= (getResizeY() + 6)){
			return true;
		}
		return false;
	}
	public abstract void setWidth(int width);
	public abstract void setHeight(int height);
	/**	 * Checks the state of the object and whether it is currently transparent	 * @return true if the object is currently transparent	 */
	public boolean isTransparent() {
		return isTransparent;
	}
	/**
	 * Sets the state of the object to either be transparent or opaque
	 * @param transparent set to true if the object is transparent.
	 */
	public void setTransparent(boolean transparent){
		isTransparent = transparent;
	}
	/**
	 * Sets the fill colour of the object
	 * @param newColour an {@link java.awt.Color} object modelling the colour that the object will be filled with
	 */
	public void setFillColour(Color newColour){
		this.fillColour = newColour;
	}
	/**
	 * Create a new fill colour using RGB values
	 * 
	 * @param red the red component of RGB to fill the object with
	 * @param green the green component of RGB to fill the object with
	 * @param blue the blue component of RGB to fill the object with
	 */
	public void setFillColourRGB(int red, int green, int blue){
		this.fillColour = new Color(red, green, blue);
	}
	/**
	 * Sets the text colour of the object
	 * @param newColour an {@link java.awt.Color} object modelling the colour that the text will be
	 */
	public void setTextColour(Color newColour){
		this.textColour = newColour;
	}
	
	/**
	 * Create the text colour using RGB values
	 * 
	 * @param red the red component of RGB that the text colour will be
	 * @param green the green component of RGB that the text colour will be
	 * @param blue the blue component of RGB that the text colour will be
	 */
	public void setTextColourRGB(int red, int green, int blue){
		this.textColour = new Color(red, green, blue);
	}
	/**
	 * Gets the currently filled colour of the object
	 * @return current fill colour of box
	 */
	public Color getFillColour(){
		return this.fillColour;
	}
	
	/**
	 * Returns the red RGB value of the fill colour
	 * @return the red RGB value
	 */
	public int getFillColourRed(){
		return fillColour.getRed();
	}

	/**
	 * Returns the green RGB value of the fill colour
	 * @return the green RGB value
	 */
	public int getFillColourGreen(){
		return fillColour.getGreen();
	}

	/**
	 * Returns the blue RGB value of the fill colour
	 * @return the blue RGB value
	 */
	public int getFillColourBlue(){
		return fillColour.getBlue();
	}
	/**
	 * Gets the current text colour of the object
	 * @return current text colour of box
	 */
	public Color getTextColour(){
		return this.textColour;
	}
	/**
	 * Returns the red RGB value of the text colour
	 * @return the red RGB value
	 */
	public int getTextColourRed(){
		return textColour.getRed();
	}
	
	/**
	 * Returns the green RGB value of the text colour
	 * @return the green RGB value
	 */
	public int getTextColourGreen(){
		return textColour.getGreen();
	}
	
	/**
	 * Returns the blue RGB value of the text colour
	 * @return the blue RGB value
	 */
	public int getTextColourBlue(){
		return textColour.getBlue();
	}	/**	 * Gets the name of the object	 * @return the string representation of the name of the object	 */
	public String getName() {
		return this.name;
	}	/**	 * Sets the name of the object	 * @param name the name of the object	 */
	public void setName(String name) {
		this.name = name;
	}
}